import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

var PanelContent = function (_Component) {
  _inherits(PanelContent, _Component);

  function PanelContent() {
    _classCallCheck(this, PanelContent);

    return _possibleConstructorReturn(this, _Component.apply(this, arguments));
  }

  PanelContent.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
    return this.props.forceRender || this.props.isActive || nextProps.isActive;
  };

  PanelContent.prototype.render = function render() {
    var _classnames;

    this._isActived = this.props.forceRender || this._isActived || this.props.isActive;
    if (!this._isActived) {
      return null;
    }
    var _props = this.props,
        prefixCls = _props.prefixCls,
        isActive = _props.isActive,
        children = _props.children,
        destroyInactivePanel = _props.destroyInactivePanel,
        forceRender = _props.forceRender,
        role = _props.role;

    var contentCls = classnames((_classnames = {}, _defineProperty(_classnames, prefixCls + '-content', true), _defineProperty(_classnames, prefixCls + '-content-active', isActive), _defineProperty(_classnames, prefixCls + '-content-inactive', !isActive), _classnames));
    var child = !forceRender && !isActive && destroyInactivePanel ? null : React.createElement(
      'div',
      { className: prefixCls + '-content-box' },
      children
    );
    return React.createElement(
      'div',
      {
        className: contentCls,
        role: role
      },
      child
    );
  };

  return PanelContent;
}(Component);

PanelContent.propTypes = {
  prefixCls: PropTypes.string,
  isActive: PropTypes.bool,
  children: PropTypes.any,
  destroyInactivePanel: PropTypes.bool,
  forceRender: PropTypes.bool,
  role: PropTypes.string
};

export default PanelContent;